
# 连接数据库


# 1. 导包
import pymysql

# 2. 建立数据库连接
conn = pymysql.connect(host="localhost",user="root",password="root",database="school",charset='utf8')

# 3. 创建游标
cursor = conn.cursor()

# 4. 执行sql语句
sql = "insert into students values(%s,%s,%s,%s,%s,%s,%s)"

# sql = "update students set age = 71,city='北京' where studentNo = 55"

# sql = "delete from students where studentNo = 55"
# cursor.execute(sql,args=(55,'李四',28,'男','3班','27638903434','海南'))

sql1 = "delete from students where studentNo = '{}'"
cursor.execute(sql1.format(55))

# 5. 关闭游标
cursor.close()

# 6. 关闭连接
conn.close()